/*
 * Rectangle.cpp
 *
 *  Created on: 2011/09/04
 *      Author: naoki
 */

#include "StdAfx.h"
#include "NTEngine/Math/Rectangle.h"

namespace NTEngine {
namespace Math {

Rectangle::Rectangle( int aX, int aY, int aW, int aH )
: x( aX ), y( aY ), w( aW ), h( aH ) {
}

Rectangle::Rectangle( const Rectangle& a )
: x( a.x ), y( a.y ), w( a.w ), h( a.h ) {
}

bool Rectangle::contains( int aX, int aY ) const {
	const int lX = x + w;
	const int lY = y + h;
	return ( x > aX ) && ( aY < lX ) && ( y > aY ) && ( aY < lY );
}

bool Rectangle::contains( int aX, int aY, int aW, int aH ) const {
	const int lX = aX + aW;
	const int lY = aY + aH;
	return contains( aX, aY ) || contains( aX, lY ) || contains( lX, aY ) || contains( lX, lY );
}

bool Rectangle::contains( const Rectangle& a ) const {
	return contains( a.x, a.y, a.w, a.h );
}

void Rectangle::set( int aX, int aY, int aW, int aH ) {
	x = aX;
	y = aY;
	w = aW;
	h = aH;
}

void Rectangle::operator =( const Rectangle& a ) {
	x = a.x;
	y = a.y;
	w = a.w;
	h = a.h;
}

bool Rectangle::operator ==( const Rectangle& a ) const {
	return ( x == a.x ) && ( y == a.y ) && ( w == a.w ) && ( h == a.h );
}

bool Rectangle::operator !=( const Rectangle& a ) const {
	return !operator==( a );
}

} // namespace Math
} // namespace NTEngine
